const mongoose = require('mongoose');
const Schema = mongoose.Schema;

// 角色模型
const RoleSchema = new Schema({
  name: {
    type: String,
    required: true,
    unique: true,
    comment: '角色名称'
  },
  code: {
    type: String,
    required: true,
    unique: true,
    comment: '角色代码'
  },
  order: {
    type: Number,
    default: 0,
    comment: '角色顺序'
  },
  status: {
    type: String,
    enum: ['正常', '停用'],
    default: '正常',
    comment: '状态'
  },
  permissions: [{
    type: Schema.Types.ObjectId,
    ref: 'Permission',
    comment: '关联的权限'
  }]
});

module.exports = mongoose.model('Role', RoleSchema);